{==============================================================================}
{  Acroprise Multi-Language Components                                         }
{                                                                              }
{  Copyright (C), 1999-2012, Acroprise Inc.                                    }
{  http://www.acroprise.com.tw                                                 }
{  ALL RIGHTS RESERVED                                                         }
{                                                                              }
{  Author   : Mustapha.Wang                                                    }
{  Version  : 4.1.15.2159                                                      }
{  Creation : 2002/05/06                                                       }
{  Revision :                                                                  }
{  Task     :                                                                  }
{==============================================================================}
unit acroMultiFramework_vcl;
{$I acroMultiLang.Inc}
interface

uses
  Classes,
  {$IFDEF Delphi15High}
  System.UITypes,System.SysUtils,
  {$ELSE}
  Dialogs,SysUtils,
  {$ENDIF}
  {$IFNDEF Delphi15High}
  Forms,Controls,
  {$ELSE}
  vcl.Forms,vcl.Dialogs,vcl.Controls,
  {$ENDIF}
  acroDelphiClassMethod_vcl,
  acroMultiInterface;

type
  TFramework_vcl=class(TComponent,IMultiFramework)
  protected
    function  GetApplicationExeName:string;
    function  GetApplicationTitle:string;

    procedure ShowMessage(const AMsg:string);
    function  MessageDlg(const Msg: string; DlgType: TMsgDlgType;
              Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;

    function  GetScreenFormCount:integer;virtual;
    function  GetScreenForm(const Index:integer):TComponent;virtual;

    function  GetFormHandle(AForm:TObject):THandle;
    function  IsFormHandleAllocated(AForm:TObject):Boolean;
    function  InstanceIsForm(AInstance:TObject):Boolean;

    function  InstanceIsWinControl(AInstance:TObject):Boolean;
    function  GetWinControlChildrenCount(AControl:TObject):integer;
    function  GetWinControlChild(AControl:TObject;const Index:integer):TComponent;

    function  InstanceIsControl(AInstance:TObject):Boolean;
    function  GetControlParent(AControl:TObject):TComponent;
    function  GetControlHint(AControl:TObject):string;
    procedure SetControlHint(AControl:TObject;AHint:string);
  end;

implementation

{ TFramework_vcl }

var
  oFramework_vcl:TFramework_vcl;

function TFramework_vcl.GetApplicationExeName: string;
begin
  Result:=Application.ExeName;
end;

function TFramework_vcl.GetApplicationTitle: string;
begin
  Result:=Application.Title;
end;

function TFramework_vcl.GetWinControlChild(AControl:TObject;const Index: integer): TComponent;
begin
  Result:=TWinControl(AControl).Controls[Index];
end;

function TFramework_vcl.GetWinControlChildrenCount(AControl: TObject): integer;
begin
  Result:=TWinControl(AControl).ControlCount;
end;

function TFramework_vcl.GetControlHint(AControl: TObject): string;
begin
  Result:=TControl(AControl).Hint;
end;

function TFramework_vcl.GetControlParent(AControl: TObject): TComponent;
begin
  Result:=TControl(AControl).Parent;
end;

function TFramework_vcl.GetFormHandle(AForm: TObject): THandle;
begin
  Result:=TCustomForm(AForm).Handle;
end;

function TFramework_vcl.GetScreenForm(const Index: integer): TComponent;
begin
  Result:=Screen.Forms[Index];
end;

function TFramework_vcl.GetScreenFormCount: integer;
begin
  Result:=Screen.FormCount;
end;

function TFramework_vcl.InstanceIsControl(AInstance: TObject): Boolean;
begin
  Result:=AInstance is TControl;
end;

function TFramework_vcl.InstanceIsForm(AInstance: TObject): Boolean;
begin
  Result:=AInstance is TCustomForm;
end;

function TFramework_vcl.InstanceIsWinControl(AInstance: TObject): Boolean;
begin
  Result:=AInstance is TWinControl;
end;

function TFramework_vcl.IsFormHandleAllocated(AForm: TObject): Boolean;
begin
  Result:=TCustomForm(AForm).HandleAllocated;
end;

function TFramework_vcl.MessageDlg(const Msg: string; DlgType: TMsgDlgType;
  Buttons: TMsgDlgButtons; HelpCtx: Integer): Integer;
begin
  Result:={$IFNDEF Delphi15High}Dialogs{$ELSE}vcl.Dialogs{$ENDIF}.MessageDlg(Msg,DlgType,Buttons,HelpCtx);
end;

procedure TFramework_vcl.SetControlHint(AControl: TObject; AHint: string);
begin
  TControl(AControl).Hint:=AHint;
end;

procedure TFramework_vcl.ShowMessage(const AMsg: string);
begin
  {$IFNDEF Delphi15High}Dialogs{$ELSE}vcl.Dialogs{$ENDIF}.ShowMessage(AMsg);
end;

initialization
  oFramework_vcl:=TFramework_vcl.Create(nil);
  g_MultiFramework:=oFramework_vcl;
finalization
  g_MultiFramework:=nil;
  FreeAndNil(oFramework_vcl);
end.
